package com.yuanlrc.base.entity.admin;

import com.yuanlrc.base.annotion.ValidateEntity;

import javax.persistence.*;

/**
 * 图书的分类
 */
@Entity
@Table(name = "ylrc_book_category")
public class BookCategory extends BaseEntity {
    @ValidateEntity(required=true,requiredLeng=true,minLength=1,maxLength=18,errorRequiredMsg="分类名不能为空!",errorMinLengthMsg="分类名长度需大于1!",errorMaxLengthMsg="分类名长度不能大于18!")
    @Column(name="type_name",nullable=false,length=18)
    private String typeName;//分类名称

    @ManyToOne
    @JoinColumn(name="parent_id")
    private BookCategory parent;;//分类父分类

    @Override
    public String toString() {
        return "BookCategory{" +
                "typeName='" + typeName + '\'' +
                ", parent=" + parent +
                '}';
    }

    public BookCategory(String typeName, BookCategory parent) {
        this.typeName = typeName;
        this.parent = parent;
    }

    public BookCategory() {
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public BookCategory getParent() {
        return parent;
    }

    public void setParent(BookCategory parent) {
        this.parent = parent;
    }


}
